//计算两个时间之间的时间差 多少天
function diffDay(expireTime) {
    // var timestamp=new Date().getTime(); //计算当前时间戳
    var timestamp = (Date.parse(new Date()))/1000;//计算当前时间戳 (毫秒级)
    var days = 0;
    if(expireTime>timestamp){
        days = (expireTime - timestamp) * 1000;
		days = Math.ceil(days / (24 * 3600 * 1000));
    }
	console.log(days);
    return days;
}

// 插屏广告
var interstitialAd = null;
let interstitial = {
	//id就是传入的广告位id
	load(id) {
		if (uni.createInterstitialAd) {
			interstitialAd = uni.createInterstitialAd({
				adUnitId: id
			})
			interstitialAd.onLoad(() => {
				
			})
			interstitialAd.onError((err) => {
				console.error(err)
			})
			interstitialAd.onClose((res) => {
				
			})
		}
	},
	show() {
		if (interstitialAd) {
			interstitialAd.show().catch((err) => {
				console.error(err)
			})
		}
	}
}

module.exports = {
    diffDay,interstitial
}